VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "ClsServicio"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Public WithEvents orset As ClsRecordset
Attribute orset.VB_VarHelpID = -1

Public Event DataChanged()

Public codigo As String
Public codTipo As String
Public nombre As String
Public descripcion As String
Public habil As Boolean
Public fechacreacion As String

Private Sub Class_Initialize()
    Set orset = New ClsRecordset
    orset.setCampos dbCampos(ser)
    orset.setTablas Array(ser)
End Sub
Private Sub Class_Terminate()
    Set orset = Nothing
End Sub
Public Sub consulta()
    'siempre consulta por permisos
    If GUsuario.tipo_id <> "1" Then
        orset.consultaGral , Array(ser, tse, per), _
                           Array(ser_tse_id & "=" & tse_id, _
                                 per_tse_id & "=" & tse_id, _
                                 per_tus_id & "=" & GUsuario.tipo_id), _
                           Array(ser_tse_id, ser_nombre)
    Else
        orset.consulta , Array(ser_tse_id, ser_nombre)
    End If
End Sub
Public Sub consultaGral(Optional condiciones As Variant, Optional orden As Variant)
    orset.consulta condiciones, orden
End Sub
Public Sub consultaDatos(codig As String)
    orset.consulta Array(ser_id & "=" & codig)
    orset.CierraRec
End Sub
Public Sub consultaXTipoServicio(tipoServicioCod As String)
    orset.consulta Array(ser_tse_id & "=" & tipoServicioCod), Array(ser_nombre & " DESC")
End Sub
Public Sub consultaCuotasAsociados(gestion As String)
    orset.consulta Array(ser_tse_id & "=1", ser_nombre & " LIKE '%" & gestion & "%'")
    orset.CierraRec
End Sub
'metodos derivados de las antiguas propiedades
Public Function detalleNecesario() As Integer
    Dim detalles As ClsDetalle
    Set detalles = New ClsDetalle
    detalles.consultaServicio Me.codigo
    If detalles.orset.numRegistros > 0 Then
        detalleNecesario = 1
    Else
        detalleNecesario = 0
    End If
    Set detalles = Nothing
End Function
Public Function tienePrecio() As Integer
    Dim precios As ClsPrecio
    Set precios = New ClsPrecio
    precios.consulta Me.codigo
    If precios.orset.numRegistros > 0 Then
        tienePrecio = 1
    Else
        tienePrecio = 0
    End If
    Set precios = Nothing
End Function

'Metodos para base de datos
Public Sub Nuevo(newTseId As String, newNombre As String, newDescripcion As String, newHabil As String, newFechaCreacion As String)
    orset.sInsert Array("", newTseId, newNombre, newDescripcion, newHabil, newFechaCreacion)
End Sub
Public Sub Modificar(codig As String, newTseId As String, newNombre As String, newDescripcion As String, newHabil As String, newFechaCreacion As String)
    orset.sUpdate Array(codig, newTseId, newNombre, newDescripcion, newHabil, newFechaCreacion)
End Sub
Public Sub Borrar(codig As String)
    orset.sDelete Array(ser_id & "=" & codig)
End Sub
Private Sub Reload_members()
    With orset
        codigo = .getDato(ser_id)
        nombre = .getDato(ser_nombre)
        codTipo = .getDato(ser_tse_id)
        descripcion = .getDato(ser_descripcion)
        habil = .getDato(ser_habil)
        fechacreacion = .getDato(ser_fecha_creacion)
    End With
    RaiseEvent DataChanged
End Sub
Private Sub orset_DataChanged()
    Reload_members
End Sub
